home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / c-runtime / patches / tm.hack < prev   
Encoding:
Text File  |  1992-08-18  |  14.8 KB  |  450 lines

  1. /* next.h:  definitions for NeXT.
  2.  
  3. This file is part of GNU CC.
  4.  
  5. GNU CC is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. GNU CC is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with GNU CC; see the file COPYING.  If not, write to
  17. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #include "m68k.h"
  20.  
  21. #define EXTRA_FORMAT_FUNCTIONS \
  22.       "NXPrintf",    FALSE,    2,    FALSE,    \
  23.       "NXScanf",    TRUE,    2,    FALSE,    \
  24.       "NXVPrintf",    FALSE,    2,    TRUE,    \
  25.       "NXVScanf",    TRUE,    2,    TRUE,    \
  26.       "DPSPrintf",    FALSE,    2,    FALSE,    \
  27.       "bsd_sprintf",    FALSE,    2,    FALSE,    \
  28.       "bsd_vsprintf",    FALSE,    2,    TRUE,
  29.  
  30. /* Use NeXT's special calling convention for sending an Objc message.  */
  31. #undef NEXT_OBJC_RUNTIME
  32.  
  33. /* We have atexit.  */
  34. #define HAVE_ATEXIT
  35.  
  36. /* Enable recent gcc to compile under the old gcc in Next release 1.0.  */
  37. #define __inline inline
  38.  
  39. /* See m68k.h.  0407 means 68040 (or 68030 or 68020, with 68881/2).  */
  40.  
  41. #define TARGET_DEFAULT 0407
  42.  
  43. /* wchar_t is unsigned short */
  44.  
  45. #undef WCHAR_TYPE
  46. #undef WCHAR_TYPE_SIZE
  47. #define WCHAR_TYPE "short unsigned int"
  48. #define WCHAR_TYPE_SIZE (BITS_PER_WORD / 2)
  49.  
  50. /* Give methods pretty symbol names on NeXT. */
  51.  
  52. #define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME)    \
  53.   do { if (CAT_NAME)                            \
  54.      sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+',        \
  55.           (CLASS_NAME), (CAT_NAME), (SEL_NAME));        \
  56.        else                                \
  57.      sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+',        \
  58.           (CLASS_NAME), (SEL_NAME));                \
  59.      } while (0)
  60.  
  61. /* Wrap new method names in quotes so the assembler doesn't gag.
  62.    Make Objective-C internal symbols local.  */
  63.  
  64. #undef ASM_OUTPUT_LABELREF
  65. #define ASM_OUTPUT_LABELREF(FILE,NAME)    \
  66.   do { if (NAME[0] == '+' || NAME[0] == '-') fprintf (FILE, "\"%s\"", NAME); \
  67.        else if (!strncmp (NAME, "_OBJC_", 6)) fprintf (FILE, "L%s", NAME);   \
  68.        else if (!strncmp (NAME, ".objc_class_name_", 17))        \
  69.      fprintf (FILE, "%s", NAME);                    \
  70.        else fprintf (FILE, "_%s", NAME); } while (0)
  71.  
  72. #undef STACK_BOUNDARY
  73. /* Boundary (in *bits*) on which stack pointer should be aligned.  */
  74. #define STACK_BOUNDARY 32
  75.  
  76. /* These compiler options take n arguments.  */
  77.  
  78. #define WORD_SWITCH_TAKES_ARG(STR)         \
  79.   (!strcmp (STR, "Ttext") ? 1 :            \
  80.    !strcmp (STR, "Tdata") ? 1 :            \
  81.    !strcmp (STR, "include") ? 1 :        \
  82.    !strcmp (STR, "imacros") ? 1 :        \
  83.    !strcmp (STR, "segalign") ? 1 :        \
  84.    !strcmp (STR, "seg1addr") ? 1 :        \
  85.    !strcmp (STR, "segaddr") ? 2 :        \
  86.    !strcmp (STR, "sectobjectsymbols") ? 2 :    \
  87.    !strcmp (STR, "segprot") ? 3 :        \
  88.    !strcmp (STR, "sectcreate") ? 3 :        \
  89.    !strcmp (STR, "sectalign") ? 3 :        \
  90.    !strcmp (STR, "segcreate") ? 3 :        \
  91.    !strcmp (STR, "sectorder") ? 3 :        \
  92.    !strcmp (STR, "aux-info") ? 1 :        \
  93.    0)
  94.  
  95. /* Names to predefine in the preprocessor for this target machine.  */
  96.  
  97. #define CPP_PREDEFINES "-Dmc68000 -Dm68k -DNeXT -Dunix -D__MACH__"
  98.  
  99. /* Machine dependent ccp options.  */
  100.  
  101. /* This option used to be called -bsd, but that conflicts with the
  102.    general -b option.  */
  103. #define CPP_SPEC "%{strict-bsd:-D__STRICT_BSD__}"
  104.  
  105. /* Machine dependent ld options.  */
  106.  
  107. #define LINK_SPEC "%{Z} %{M} \
  108. %{execute*} %{object*} %{preload*} %{fvmlib*} \
  109. %{segalign*} %{seg1addr*} %{segaddr*} %{segprot*} \
  110. %{seglinkedit*} %{noseglinkedit*} \
  111. %{sectcreate*} %{sectalign*} %{sectobjectsymbols}\
  112. %{segcreate*} %{Mach*} %{whyload} %{w} \
  113. %{sectorder*} %{whatsloaded}"
  114.  
  115. /* Machine dependent libraries.  */
  116.  
  117. #define LIB_SPEC "%{!p:%{!pg:-lsys_s}} %{pg:-lsys_p}"
  118.  
  119. /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
  120. #define STARTFILE_SPEC  \
  121.   "%{pg:-lgcrt0.o}%{!pg: \
  122.      %{p:%e-p profiling is no longer supported.  Use -pg instead.} \
  123.      %{!p:-lcrt0.o}}"
  124.  
  125. /* Every structure or union's size must be a multiple of 2 bytes.
  126.    (Why isn't this in m68k.h?)  */
  127.  
  128. #define STRUCTURE_SIZE_BOUNDARY 16
  129.  
  130. /* Why not? */
  131.  
  132. #define DOLLARS_IN_IDENTIFIERS 2
  133.  
  134. /* Allow #sscs (but don't do anything). */
  135.  
  136. #define SCCS_DIRECTIVE
  137.  
  138. /* We use Dbx symbol format.  */
  139.  
  140. #define DBX_DEBUGGING_INFO
  141.  
  142. /* This saves a fair amount of space. */
  143.  
  144. #define DBX_CONTIN_LENGTH 0
  145.  
  146. /* These screw up NeXT's gdb at the moment, so don't use them. */
  147.  
  148. #define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(FILE, FILENAME)
  149.  
  150. /* gdb needs a null N_SO at the end of each file for scattered loading. */
  151.  
  152. #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME)            \
  153.   fprintf (FILE,                            \
  154.        "\t.text\n\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n",        \
  155.        "" , N_SO)
  156.  
  157. /* Don't use .gcc_compiled symbols to communicate with GDB;
  158.    They interfere with numerically sorted symbol lists. */
  159.  
  160. #define ASM_IDENTIFY_GCC(asm_out_file)
  161.  
  162. /* This is how to output an assembler line defining a `double' constant.  */
  163.  
  164. #undef ASM_OUTPUT_DOUBLE
  165. #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                    \
  166.   (REAL_VALUE_ISINF ((VALUE))                        \
  167.    ? fprintf (FILE, "\t.double 0r%s99e999\n", ((VALUE) > 0 ? "" : "-")) \
  168.    : fprintf (FILE, "\t.double 0r%.20e\n", (VALUE)))
  169.  
  170. /* This is how to output an assembler line defining a `float' constant.  */
  171.  
  172. #undef ASM_OUTPUT_FLOAT
  173. #define ASM_OUTPUT_FLOAT(FILE,VALUE)                    \
  174.   (REAL_VALUE_ISINF ((VALUE))                        \
  175.    ? fprintf (FILE, "\t.single 0r%s99e999\n", ((VALUE) > 0 ? "" : "-")) \
  176.    : fprintf (FILE, "\t.single 0r%.20e\n", (VALUE)))
  177.  
  178. #undef ASM_OUTPUT_FLOAT_OPERAND
  179. #define ASM_OUTPUT_FLOAT_OPERAND(FILE,VALUE)                \
  180.   (REAL_VALUE_ISINF ((VALUE))                        \
  181.    ? fprintf (FILE, "#0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
  182.    : fprintf (FILE, "#0r%.9g", (VALUE)))
  183.  
  184. #undef ASM_OUTPUT_DOUBLE_OPERAND
  185. #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE)                \
  186.   (REAL_VALUE_ISINF ((VALUE))                        \
  187.    ? fprintf (FILE, "#0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
  188.    : fprintf (FILE, "#0r%.20g", (VALUE)))
  189.  
  190. #if 0 /* This is for system verson 3.0, which isn't out yet.  */
  191. #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)    \
  192.   do { constructor_section ();            \
  193.        ASM_OUTPUT_ALIGN (FILE, 1);        \
  194.        fprintf (FILE, "\t.long ");        \
  195.        assemble_name (FILE, NAME);        \
  196.        fprintf (FILE, "\n"); } while (0)
  197.  
  198. #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)    \
  199.   do { destructor_section ();            \
  200.        ASM_OUTPUT_ALIGN (FILE, 1);        \
  201.        fprintf (FILE, "\t.long ");        \
  202.        assemble_name (FILE, NAME);        \
  203.        fprintf (FILE, "\n"); } while (0)
  204. #else
  205. #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)    \
  206.       fprintf (asm_out_file, "%s \"___CTOR_LIST__\",32,0,0,", ASM_STABS_OP); \
  207.       assemble_name (asm_out_file, name); \
  208.       fputc ('\n', asm_out_file);
  209.  
  210. #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)    \
  211.       fprintf (asm_out_file, "%s \"___DTOR_LIST__\",32,0,0,", ASM_STABS_OP); \
  212.       assemble_name (asm_out_file, name); \
  213.       fputc ('\n', asm_out_file);
  214.  
  215. #endif
  216.  
  217. /* How to parse #pragma's */
  218.  
  219. #define HANDLE_PRAGMA(finput) handle_pragma (finput)
  220.  
  221. /* Create new Mach-O sections. */
  222. #if 0
  223. #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, WAS_TEXT)    \
  224. void                                    \
  225. FUNCTION ()                                \
  226. {                                    \
  227.   extern void text_section ();                         \
  228.   extern int flag_no_mach_text_sections;                       \
  229.                                       \
  230.   if (WAS_TEXT && flag_no_mach_text_sections)                   \
  231.     text_section ();                            \
  232.   else if (in_section != SECTION)                    \
  233.     {                                    \
  234.       fprintf (asm_out_file, "%s\n", DIRECTIVE);            \
  235.       in_section = SECTION;                        \
  236.     }                                    \
  237. }                                    \
  238.  
  239. #define EXTRA_SECTIONS                    \
  240.   in_const, in_cstring, in_literal4, in_literal8,    \
  241.   in_constructor, in_destructor,            \
  242.   in_objc_class, in_objc_meta_class, in_objc_category,    \
  243.   in_objc_class_vars, in_objc_instance_vars,        \
  244.   in_objc_cls_meth, in_objc_inst_meth,            \
  245.   in_objc_cat_cls_meth, in_objc_cat_inst_meth,        \
  246.   in_objc_selector_strs, in_objc_selector_refs,        \
  247.   in_objc_symbols, in_objc_module_info
  248.  
  249. #define EXTRA_SECTION_FUNCTIONS            \
  250. SECTION_FUNCTION (const_section,        \
  251.           in_const,            \
  252.           ".const", 1)            \
  253. SECTION_FUNCTION (cstring_section,        \
  254.           in_cstring,            \
  255.           ".cstring", 1)        \
  256. SECTION_FUNCTION (literal4_section,        \
  257.           in_literal4,            \
  258.           ".literal4", 1)        \
  259. SECTION_FUNCTION (literal8_section,        \
  260.           in_literal8,            \
  261.           ".literal8", 1)        \
  262. SECTION_FUNCTION (constructor_section,        \
  263.           in_constructor,        \
  264.           ".constructor", 0)        \
  265. SECTION_FUNCTION (destructor_section,        \
  266.           in_destructor,        \
  267.           ".destructor", 0)        \
  268. SECTION_FUNCTION (objc_class_section,        \
  269.           in_objc_class,        \
  270.           ".objc_class", 0)        \
  271. SECTION_FUNCTION (objc_meta_class_section,    \
  272.           in_objc_meta_class,        \
  273.           ".objc_meta_class", 0)    \
  274. SECTION_FUNCTION (objc_category_section,    \
  275.           in_objc_category,        \
  276.         ".objc_category", 0)        \
  277. SECTION_FUNCTION (objc_class_vars_section,    \
  278.           in_objc_class_vars,        \
  279.           ".objc_class_vars", 0)    \
  280. SECTION_FUNCTION (objc_instance_vars_section,    \
  281.           in_objc_instance_vars,    \
  282.           ".objc_instance_vars", 0)    \
  283. SECTION_FUNCTION (objc_cls_meth_section,    \
  284.           in_objc_cls_meth,        \
  285.           ".objc_cls_meth", 0)        \
  286. SECTION_FUNCTION (objc_inst_meth_section,    \
  287.           in_objc_inst_meth,        \
  288.           ".objc_inst_meth", 0)        \
  289. SECTION_FUNCTION (objc_cat_cls_meth_section,    \
  290.           in_objc_cat_cls_meth,        \
  291.           ".objc_cat_cls_meth", 0)    \
  292. SECTION_FUNCTION (objc_cat_inst_meth_section,    \
  293.           in_objc_cat_inst_meth,    \
  294.           ".objc_cat_inst_meth", 0)    \
  295. SECTION_FUNCTION (objc_selector_strs_section,    \
  296.           in_objc_selector_strs,    \
  297.           ".objc_selector_strs", 0)    \
  298. SECTION_FUNCTION (objc_selector_refs_section,    \
  299.           in_objc_selector_refs,    \
  300.           ".objc_selector_refs", 0)    \
  301. SECTION_FUNCTION (objc_symbols_section,        \
  302.           in_objc_symbols,        \
  303.           ".objc_symbols", 0)        \
  304. SECTION_FUNCTION (objc_module_info_section,    \
  305.           in_objc_module_info,        \
  306.           ".objc_module_info", 0)
  307.  
  308. #define READONLY_DATA_SECTION const_section
  309.  
  310. #define SELECT_SECTION(exp,reloc)                \
  311.   do                                \
  312.     {                                \
  313.       if (TREE_CODE (exp) == STRING_CST)            \
  314.     {                            \
  315.       if (flag_writable_strings)                \
  316.         data_section ();                    \
  317.       else if (TREE_STRING_LENGTH (exp) !=            \
  318.            strlen (TREE_STRING_POINTER (exp)) + 1)    \
  319.         readonly_data_section ();                \
  320.       else                            \
  321.         cstring_section ();                    \
  322.     }                            \
  323.       else if (TREE_CODE (exp) == INTEGER_CST            \
  324.            || TREE_CODE (exp) == REAL_CST)            \
  325.         {                            \
  326.       tree size = TYPE_SIZE (TREE_TYPE (exp));        \
  327.                                   \
  328.       if (TREE_CODE (size) == INTEGER_CST &&        \
  329.           TREE_INT_CST_LOW (size) == 4 &&            \
  330.           TREE_INT_CST_HIGH (size) == 0)            \
  331.         literal4_section ();                \
  332.       else if (TREE_CODE (size) == INTEGER_CST &&        \
  333.           TREE_INT_CST_LOW (size) == 8 &&            \
  334.           TREE_INT_CST_HIGH (size) == 0)            \
  335.         literal8_section ();                \
  336.       else                            \
  337.         readonly_data_section ();                \
  338.     }                            \
  339.       else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))    \
  340.            && !TREE_SIDE_EFFECTS (exp))                \
  341.     readonly_data_section ();                    \
  342.       else if (TREE_CODE (exp) == VAR_DECL &&                \
  343.            DECL_NAME (exp) &&                    \
  344.            TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE &&    \
  345.            IDENTIFIER_POINTER (DECL_NAME (exp)) &&            \
  346.            !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \
  347.     {                                \
  348.       const char *name = IDENTIFIER_POINTER (DECL_NAME (exp));    \
  349.                                       \
  350.       if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))        \
  351.         objc_cls_meth_section ();                    \
  352.       else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))    \
  353.         objc_inst_meth_section ();                    \
  354.       else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \
  355.         objc_cat_cls_meth_section ();                \
  356.       else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \
  357.         objc_cat_inst_meth_section ();                \
  358.       else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22))    \
  359.         objc_class_vars_section ();                    \
  360.       else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25))    \
  361.         objc_instance_vars_section ();                \
  362.       else if (!strncmp (name, "_OBJC_CLASS_", 12))            \
  363.         objc_class_section ();                    \
  364.       else if (!strncmp (name, "_OBJC_METACLASS_", 16))        \
  365.         objc_meta_class_section ();                    \
  366.       else if (!strncmp (name, "_OBJC_CATEGORY_", 15))        \
  367.         objc_category_section ();                    \
  368.       else if (!strncmp (name, "_OBJC_STRINGS", 13))        \
  369.         objc_selector_strs_section ();                \
  370.       else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25))    \
  371.         objc_selector_refs_section ();                \
  372.       else if (!strncmp (name, "_OBJC_SYMBOLS", 13))        \
  373.         objc_symbols_section ();                    \
  374.       else if (!strncmp (name, "_OBJC_MODULES", 13))        \
  375.         objc_module_info_section ();                \
  376.       else                                \
  377.         data_section ();                        \
  378.     }                                \
  379.       else                                \
  380.         data_section ();                        \
  381.     }                                    \
  382.   while (0)
  383.  
  384. /* Force the assembler to create all the Objective-C sections,
  385.     so that their order is guaranteed. */
  386.   
  387. #define OBJC_PROLOGUE                    \
  388.   do {                            \
  389.     extern void objc_class_section ();        \
  390.     extern void objc_meta_class_section ();        \
  391.     extern void objc_cat_cls_meth_section ();    \
  392.     extern void objc_cat_inst_meth_section ();    \
  393.     extern void objc_cls_meth_section ();        \
  394.     extern void objc_inst_meth_section ();        \
  395.     extern void objc_selector_refs_section ();    \
  396.     extern void objc_symbols_section ();        \
  397.     extern void objc_category_section ();        \
  398.     extern void objc_class_vars_section ();        \
  399.     extern void objc_instance_vars_section ();    \
  400.     extern void objc_module_info_section ();    \
  401.     extern void objc_selector_strs_section ();    \
  402.                             \
  403.     objc_class_section ();        \
  404.     objc_meta_class_section ();    \
  405.     objc_cat_cls_meth_section ();    \
  406.     objc_cat_inst_meth_section ();    \
  407.     objc_cls_meth_section ();    \
  408.     objc_inst_meth_section ();    \
  409.     objc_selector_refs_section ();    \
  410.     objc_symbols_section ();    \
  411.     objc_category_section ();    \
  412.     objc_class_vars_section ();    \
  413.     objc_instance_vars_section ();    \
  414.     objc_module_info_section ();    \
  415.     objc_selector_strs_section ();    \
  416.      } while (0)
  417. #endif
  418.  
  419. /* We do not define JUMP_TABLES_IN_TEXT_SECTION, since we wish to keep
  420.    the text section pure.  There is no point in addressing the jump
  421.    tables using pc relative addressing, since they are not in the text
  422.    section, so we undefine CASE_VECTOR_PC_RELATIVE.  This also
  423.    causes the compiler to use absolute addresses in the jump table,
  424.    so we redefine CASE_VECTOR_MODE to be SImode. */
  425.  
  426. #undef CASE_VECTOR_MODE
  427. #define CASE_VECTOR_MODE SImode
  428.  
  429. #undef CASE_VECTOR_PC_RELATIVE
  430.  
  431. /* Don't treat addresses involving labels differently from symbol names.
  432.    Previously, references to labels generated pc-relative addressing modes
  433.    while references to symbol names generated absolute addressing modes.  */
  434.  
  435. #undef GO_IF_INDEXABLE_BASE(X, ADDR)
  436. #define GO_IF_INDEXABLE_BASE(X, ADDR)    \
  437. { if (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) goto ADDR; }
  438.  
  439. #define ALIGN_ASM_OP        ".align"
  440.  
  441. #undef ASM_OUTPUT_ALIGN
  442. #define ASM_OUTPUT_ALIGN(FILE,LOG)    \
  443.   if ((LOG) != 0)            \
  444.     fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG))
  445.  
  446. /* The maximum alignment which the object file format can support.
  447.    For NeXT's Mach-O format, this is 2^15.  */
  448.  
  449. #define MAX_OFILE_ALIGNMENT 0x8000
  450.